package com.itheima.listener;

import com.itheima.utils.DistributedRedisLock;
import com.itheima.utils.RedisUtil;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class StartupListener implements ApplicationListener<ContextRefreshedEvent> {

    @Resource
    private RedisTemplate<String,Object> redisTemplate;

    @Resource
    private DistributedRedisLock distributedRedisLock;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        RedisUtil.register(redisTemplate);
        RedisUtil.registerLock(distributedRedisLock);
        System.out.println("common listener");
    }

}
